package net.xm;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

public class TodoListItem implements Comparable {
	private String id;
	private boolean completed;
	private String content;
	
	public TodoListItem(String content) {
		this.content=content;
	}
	public boolean isCompleted() {
		return completed;
	}
	public void setCompleted(boolean completed) {
		this.completed = completed;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @see java.lang.Comparable#compareTo(Object)
	 */
	public int compareTo(Object object) {
		TodoListItem myClass = (TodoListItem) object;
		return new CompareToBuilder().append(this.content, myClass.content)
				.append(this.completed, myClass.completed).append(this.id,
						myClass.id).toComparison();
	}
	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof TodoListItem)) {
			return false;
		}
		TodoListItem rhs = (TodoListItem) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(
				this.content, rhs.content)
				.append(this.completed, rhs.completed).append(this.id, rhs.id)
				.isEquals();
	}
	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-1941247617, 27829155).appendSuper(
				super.hashCode()).append(this.content).append(this.completed)
				.append(this.id).toHashCode();
	}
	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("id", this.id).append(
				"content", this.content).append("completed", this.completed)
				.toString();
	}
	
}
